home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / apb17.zip / INT.ASM < prev    next >
Assembly Source File  |  1990-12-20  |  2KB  |  75 lines

  1.     Title Subprogram to generated software interrupts
  2.     Page 60,130
  3. ;    Created 10-17-1987 k. murray
  4. ;
  5. Cseg    Segment byte public 'Code'
  6.     Assume Cs:Cseg,Ds:nothing,Es:nothing
  7. ;
  8. ;    Define in program:
  9. ;        Sub DoInt IntNo%,Reg%(1) External "Int.Com"
  10. ;    Call in program:
  11. ;        DoInt &h21,Registers%()
  12. ;
  13. ;    Stack frame:
  14. ;    Bp+14    IntNo% offset
  15. ;    Bp+12    Number of elements
  16. ;    Bp+10    Dim 1 Size
  17. ;    Bp+8    Dim 1 Low bounds
  18. ;    Bp+6    Array Offset
  19. ;    Bp+4    Return Segment
  20. ;    Bp+2    Return Offset
  21. ;    Bp+0    Saved Bp
  22. Start:
  23. DoInt    Proc Far
  24.     Push    Bp
  25.     Mov    Bp,Sp            ; Setup base pointer
  26.     Mov    Bx,[Bp+14]        ; adr. of IntNo%
  27.     Mov    Al,[Bx]            ; get low byte of IntNo%
  28.     Mov    byte ptr Cs:DoInt02,Al
  29.     Push    Ds
  30.     Push    Bp            ; save registers in case they change
  31.     Mov    Di,[Bp+6]        ; get offset of array
  32.     Push    [Di+0]            ; push Reg%(0) on stack (flags)
  33.     Mov    Ax,[Di+2]        ; Reg%(1)
  34.     Mov    Bx,[Di+4]        ; Reg%(2)
  35.     Mov    Cx,[Di+6]        ; Reg%(3)
  36.     Mov    Dx,[Di+8]        ; Reg%(4)
  37.     Mov    Si,[Di+10]        ; Reg%(5)
  38.     Push    [Di+12]            ; save Reg%(6) (Di) on stack
  39.     Mov    Bp,[Di+14]        ; Reg%(7)
  40.     Mov    Es,[Di+18]        ; Reg%(9)
  41.     Mov    Ds,[Di+16]        ; Reg%(8) (Do last)
  42.     Pop    Di            ; Get Reg%(6) off stack
  43.     Popf                ; Pop flags
  44.         ; registers setup, now do interrupt
  45.     Db    0cdh            ; initial code for INT
  46. DoInt02 Db    0            ; put interrupt # to do here
  47.         ; Done with interrupt, save registers back in array
  48.     Mov    Cs:SvBp,Bp        ; save returned Bp for later
  49.     Mov    Cs:SvDs,Ds        ; save returned Ds for later
  50.     Pop    Bp            ; get programs base pointer
  51.     Pop    Ds            ; and data segment
  52.     Push    Di
  53.     Mov    Di,[Bp+6]        ; Offset of array
  54.     Pushf                ; save flags on stack
  55.     Pop    [Di+0]            ; and pop into array Reg%(0)
  56.     Mov    [Di+2],Ax        ; Reg%(1)
  57.     Mov    [Di+4],Bx        ; Reg%(2)
  58.     Mov    [Di+6],Cx        ; Reg%(3)
  59.     Mov    [Di+8],Dx        ; Reg%(4)
  60.     Mov    [Di+10],Si        ; Reg%(5)
  61.     Pop    [Di+12]            ; Pop saved Di into Reg%(6)
  62.     Mov    Ax,Cs:SvBp        ; Get Bp and Ds into
  63.     Mov    Bx,Cs:SvDs        ; Ax and Bx
  64.     Mov    [Di+14],Ax        ; Reg%(7)
  65.     Mov    [Di+16],Bx        ; Reg%(8)
  66.     Mov    [Di+18],Es        ; Reg%(9)
  67.     Pop    Bp            ; Restore base pointer
  68.     Ret
  69. DoInt    Endp
  70.     ; Data area for program
  71. SvBp    Dw    0
  72. SvDs    Dw    0
  73. Cseg    Ends
  74.     End    Start
  75.